<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div class="grid">
    <div class="item"></div>
    <div class="item"></div>
    <div class="item"></div>
    <div class="item"></div>
    <div class="item"></div>
    <div class="item"></div>
    <div class="item"></div>
    <div class="item"></div>
  </div>
</body>
<!-- https://blog.csdn.net/yyy_wj/article/details/113175202 -->
<style>
  .grid{
    width: 400px;
    height: 200px;
    display: grid;
    /* 等分为4列 */
    grid-template-columns: repeat(4, 1fr);     
    /* 固定三列，第二列自适应 */
    /* grid-template-columns: 10px auto 20px 30px;   */
    grid-template-rows: repeat(2, 1fr);
    grid-gap: 10px;
 
  }
  .item{
    background-color: red;
  }
</style>
</html>